package com.meida.module.bus.provider.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.google.common.collect.Lists;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.common.utils.FlymeUtils;
import com.meida.module.bus.client.entity.BBpWbsarchitecture;
import com.meida.module.bus.client.entity.BmmdMaterial;
import com.meida.module.bus.provider.mapper.BBpWbsarchitectureMapper;
import com.meida.module.bus.provider.service.BBpWbsarchitectureService;
import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 接口实现类
 *
 * @author flyme
 * @date 2020-09-26
 */
@Service
@Transactional(rollbackFor = Exception.class)
@DS("dbr")
public class BBpWbsarchitectureServiceImpl extends BaseServiceImpl<BBpWbsarchitectureMapper, BBpWbsarchitecture> implements BBpWbsarchitectureService {

    @Override
    public ResultBody beforeAdd(CriteriaSave cs, BBpWbsarchitecture bbw, EntityMap extra) {
        return ResultBody.ok();
    }



    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public ResultBody beforePageList(CriteriaQuery<BBpWbsarchitecture> cq, BBpWbsarchitecture bbw, EntityMap requestMap) {
        String valueKey = requestMap.get("valueKey");
        String value = requestMap.get("value");
        cq.like(valueKey, value);
      return ResultBody.ok();
    }

    @Override
    public void afterPageList(CriteriaQuery<BBpWbsarchitecture> cq, List<EntityMap> data, ResultBody resultBody) {
        List<EntityMap> outData = Lists.newArrayList();
        data.stream().forEach(obj->{
//            EntityMap entityMap = new EntityMap();
            obj.put("wbsCode", obj.get("WBSCODE"));
//            outData.add(entityMap);
        });
//        resultBody.data(outData);
    }
}
